package com.xiaohei.article.controller;

import com.xiaohei.article.service.ArticleService;
import com.xiaohei.pojo.Article;
import com.xiaohei.pojo.QueryParams;
import entity.PageResult;
import entity.Result;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: ZhangYongLiang
 * @Date: 2020/12/15 23:23
 **/
@Api("文章模块")
@RestController
@RequestMapping("/article")
public class ArticleController {

    @Resource
    private ArticleService articleService;

    @PostMapping("/list")
    public Result<?> queryTotal(@RequestBody QueryParams params, int pageNo, int pageSize) {
        PageResult pageResult = articleService.queryTotal(params, pageNo, pageSize);
        return new Result<>(true,0000,"",pageResult);
    }

    @PostMapping("/add")
    public Result<?> add(@RequestBody Article article){
        articleService.add(article);
        return new Result<>(true,0000,"");
    }
}
